<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>	
<%@ include file="/commons/global.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <%@ include file="/commons/basejs.jsp"%> 
</head>
<style>
   .z-body{
	padding-left: 10%;
	padding-right: 10%;
	padding-top: 5%
	}
</style>
<body>

<form class="layui-form layui-form-pane">
<div class="z-body">
<div class="layui-form-item">
    <label class="layui-form-label">当前密码</label>
    <div class="layui-input-block">
      <input type="text" name="ypassword" required  lay-verify="required" placeholder="请输入原密码" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">新密码</label>
    <div class="layui-input-block">
      <input type="text" id="zpassword" name="zpassword" required  lay-verify="required" placeholder="请输入新密码" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">确认密码</label>
    <div class="layui-input-block">
      <input type="text" id="qpassword" name="qpassword" required  lay-verify="required" placeholder="请确认新密码" autocomplete="off" class="layui-input">
    </div>
  </div>
   </div>
  <div  class="" style="width: 100%;height: 42px;background-color: white;border-top:1px solid #e6e6e6;position: fixed;bottom: 1px;margin-left:0px;padding-top:6px"> 
      <div class="layui-form-item" style=" float: right;margin-right: 10%">
      <button  class="layui-btn" lay-filter="changePwd" lay-submit="">增加</button>
      <button  class="layui-btn layui-btn-primary" id="close" onclick="dream_close()">取消</button>
    </div>
  </div>
  </form>

 <script type="text/javascript">
  //自定义验证规则
  layui.form.verify({
    ypassword: function(value){
      if(value.trim() == ""){
        return '请输入原密码';
      }
    }
    ,zpassword: function(value){
      if(value.trim() == ""){
        return '请输入新密码';
      }
    }
    ,qpassword: function(value){
        var zpassword = $('#zpassword').val();
        if(value != zpassword){
        return '两次输入的密码不一致!';
      }
    }
  });
  
  // 提交监听
	layui.form.on('submit(changePwd)', function(data) {
		$.ajax({
			type : 'POST',
			url : 'changePwd',
			dataType : 'json',
			data : data.field,//往后台发送的是data.field，即一个{name：value}的数据结构
			async : false,
			success : function(result) {
			debugger;
				if (result.success) {
				    window.top.layui.layer.msg(result.msg);
				    dream_close();							   
				} else {
					 window.top.layui.layer.msg(result.msg, {
						icon : 5,//图标
						anim : 6//抖动
					});
				}
				
			}
		});
		 return false;
});

  </script>
</body>
</html>
